<?php
//DB Created by Rich L. a member in service in Northern Delaware.  Should you have questons please contact me at sobernerd@gmail.com
require_once ('config/include_paths.php');
require_once('load.php');
if ( file_exists( 'config/config.php') ) {
require_once('dbconnect.php');	// database connect script.
require_once ('functions.php');
$pageTitle = SITE_NAME.' - Home'; //must be set after the config.php include and before head.php include
require_once ('head.php'); 
$today = date("Y-m-d");  
//select and order home page modules
$page_id = 2; //home=1 contacts=4
$query  = "SELECT * FROM events
				WHERE eventDate >= '".$today."'
				ORDER BY eventDate ASC";
	$result = mysql_query($query);
$newsQuery  = "SELECT * FROM modules
				WHERE page_id = $page_id and enabled = 1
				ORDER BY record_order ASC";
	$newsResult = mysql_query($newsQuery);	
?>

<body>
<div id="wrapper">
  <?php require_once ('header.php'); ?>
  <div id="content">
  	<h2 class="sectionTitle">Events</h2>
    <hr /><br />
  	<?php while($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{ 
		$timeStamp = strtotime($row['eventDate']);
		$longDate = date('F j, Y (l)', $timeStamp);
		if($row['eventEndDate'] <> '0000-00-00') {
			$longEndDate = strtotime($row['eventEndDate']);
			$endDate = ' to '.date('F j, Y (l)', $longEndDate);;
			}else{
				$endDate = '';
				}
		?>
        <div class="module">
            <h2><?php echo $row['title'].'<span class="eventDate">'.$longDate.$endDate.'</span>';?></h2>
            <?php // now get content for module
            if ($row['system_module'] == NULL || $row['system_module'] == '')
            { 	$startTime = date("g:i a", strtotime($row['eventStartTime']));
				$endTime = date("g:i a", strtotime($row['eventEndTime']));
			
			echo '<span class="eventTime">'.$startTime.'&nbsp;to '.$endTime.'</span>';
			echo $row['editHTML']; } 
			echo '<a href="public_html/uploads/'.$row['file'].'" target="_blank" title="view/download">'.$row['file'].'</a>';?>
        </div>
	<?php } ?>
    <h2 class="sectionTitle">News</h2>
     <hr /><br />
    <?php
	while($row = mysql_fetch_array($newsResult, MYSQL_ASSOC))
	{?>
        <div class="module">
            <h2><?php echo $row['title'];?></h2>
            <?php // now get content for module
            if ($row['system_module'] == NULL || $row['system_module'] == '')
            { 
				echo $row['editHTML']; 
				echo '<a href="public_html/uploads/'.$row['file'].'" title="view/download">'.$row['file'].'</a>';
			} ?>
        </div>
	<?php }?>  
  </div>
  <div class="clearfloat">&nbsp;</div>
</div>
</body>
</html>
<?php } ?>